package com.qiyeji.real_estate.service;

import com.qiyeji.real_estate.entity.accountInformation;
import com.qiyeji.real_estate.entity.accountInformationKey;
import com.qiyeji.real_estate.mapper.accountInformationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginService {

    @Autowired
    accountInformationMapper accountinformationMapper;

    // 通过账号获取密码
    public String Login(accountInformationKey temp) {
        accountInformation data = accountinformationMapper.selectByPrimaryKey(temp);
        return data.getPassword();
    }

    //通过员工编号注册账号，每个员工只能拥有一个账号且权限与职务对等
    public Integer registerID(accountInformation temp) {
        Integer res = accountinformationMapper.insertSelective(temp);

        return res;
    }

    //通过账号和员工编号修改密码
    public Integer alterPassWord(accountInformation temp) {
        Integer res = accountinformationMapper.updateByPrimaryKey(temp);

        return res;
    }

    public String loginPower(String id,String password){
        return accountinformationMapper.loginPower(id,password);
    }

    public List<accountInformation> getAllAccountin() { return accountinformationMapper.getAllAccount(); }

    public Integer delete(accountInformationKey accountInformationKey) { return accountinformationMapper.deleteByPrimaryKey(accountInformationKey); }

}
